package cn.iocoder.yudao.module.orderview.dal.redis.orderview.snapshot;

import cn.iocoder.yudao.module.product.mq.message.ProductInfoSendMessage;
import cn.iocoder.yudao.module.promotion.mq.message.PromotionInfoSendMessage;
import cn.iocoder.yudao.module.stock.mq.message.StockInfoSendMessage;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 订单视图聚合 消息
 *
 * @author 徐煜东
 */
@Data
public class OrderViewAggregationSnapshot implements Serializable {
    public OrderViewAggregationSnapshot() {
        // Jackson 需要用的无参构造
    }
    public OrderViewAggregationSnapshot(String requestId) {
        this.requestId = requestId;
    }

    @NotNull(message = "请求ID")
    private String requestId;
    /**
     *  商品Id
     */
    private Long productId;

    /**
     *  商品信息
     */
    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "@class")
    private ProductInfoSendMessage productInfo;

    /**
     *  促销信息
     */
    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "@class")
    private PromotionInfoSendMessage promotionInfo;

    /**
     *  库存信息
     */
    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "@class")
    private StockInfoSendMessage stockInfo;

    /**
     * 判断是否所有数据块都准备好
     */
    @JsonIgnore
    public boolean isComplete() {
        return productInfo != null && stockInfo != null && promotionInfo != null;
    }

}
